<?php
	class m_collect_user extends spModel
	{
		var $pk = 'cu_id';
		var $table = "collect_user"; // 数据表的名称

		var $linker = array(  
			array(  
			   'type' => 'hasone',   // 关联类型，这里是一对一关联  
			   'map' => 'store_detail',    // 关联的标识  
			   'mapkey' => 'store_id', // 本表与对应表关联的字段名  
			   'fclass' => 'm_store', // 对应表的类名  
			   'fkey' => 'store_id',    // 对应表中关联的字段名  
			   'enabled' => true     // 启用关联  
			)
		);
		
		/*
		function addcollect()
		{
			$m_taobao = spClass('m_taobao');
			$favoritereq = new  FavoriteSearchRequest;
			$favoritereq->setUserNick($_SESSION['visitor_nick']);
			$favoritereq->setCollectType("SHOP");
			$favoritereq->setPageNo(1);
			$resp = $m_taobao->m_topsdk->execute($favoritereq);
			
			if($resp->collect_items->collect_item) {
				$collect_item = get_object_vars($resp->collect_items->collect_item);
				$collect_user = array();
				$collect_user['visitor_id'] = $_SESSION['visitor_id'];
				$this->delete(array('visitor_id'=>$collect_user['visitor_id']));
				$collect_user['visitor_nick'] = $_SESSION['visitor_nick'];
				$collect_user['collect_type'] = 'SHOP';
				foreach($resp->collect_items->collect_item as $k=>$v)
				{
					$v = get_object_vars($v);
					$collect_user['item_owner_nick'] = $v['item_owner_nick'];
					$collect_user['item_numid'] = $v['item_numid'];
					$collect_user['title'] = $v['title'];
					$this->create($collect_user);
					$result[$collect_user['visitor_id']][$collect_user['item_numid']] = $collect_user;
				}
			}
			unset($m_taobao, $resp);
			return $result;
		}
		*/

		function collect_result($visitor_nick)
		{
			if(empty($_SESSION['visitor_nick'])) return false;
			$m_taobao = spClass('m_taobao');
			$favoritereq = new  FavoriteSearchRequest;
			$favoritereq->setUserNick($_SESSION['visitor_nick']);
			$favoritereq->setCollectType("SHOP");
			$favoritereq->setPageNo(1);
			$resp = $m_taobao->m_topsdk->execute($favoritereq);
			return $resp->collect_items;
		}
	}
?>